# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=python2-celery
_pkgname=celery
pkgver=4.3.0
pkgrel=5
pkgdesc='Distributed Asynchronous Task Queue.'
arch=('any')
url='http://celeryproject.org/'
license=('BSD')
depends=('python2-kombu' 'python-billiard' 'python-pytz')
optdepends=('python2-pyopenssl: for celery.security'
            'python2-pymongo: for celery.backends.mongodb'
            'python2-msgpack: for using the msgpack serializer'
            'python2-pyro: for using Pyro4 message transport'
            'python2-redis: for celery.backends.redis'
            'python2-sqlalchemy: for celery.backends.database'
            'python2-boto: for SQS transport'
            'python2-yaml: for using the yaml serializer'
            'python2-pyzmq: for using ZeroMQ transport')
makedepends=('python2-setuptools')
source=("https://pypi.io/packages/source/c/$_pkgname/$_pkgname-$pkgver.tar.gz"
        'https://github.com/celery/celery/commit/89c4573ac47a1f840ed2d15e2820d0eaed29dc32.patch'
        'https://github.com/celery/celery/commit/6514fed13ef2f992b2846116f9b2d1237aac8298.patch'
        'celery@.service'
        'celery.tmpfiles.d')
options=('!emptydirs')
sha512sums=('91dd16bd6c9544c76d84e468872e052bdf5e1737980a1a3baee914c75c88db44b9ac8de7ddc4278988ca6cb159496b6560cecd6bb51d6352725009e97d268afb'
            '691ae1b4bf98317f6bea2d2ae26cd770c5a5242ae6b41d8d5cd0ea0ce3d521d5f3b16a1b1f33429bd777f7f628c84e29a5bada37ecb33e73c0118f9c1f992a12'
            '6c3e6da14c57cad5e26a34c5d5f59977938fbb93ae04b97b88427ca3c67b1f0ff8cf4bbfb42394ac2a6714cf847527275f99a45f6e34fb260686bb80b80d7cc4'
            '3c6c9dbdacca2de12d49c03526b34797fd867c14d04115af0d1fda64d2848a5d3f64ceb6d284be319a81d932dc86e69c157b6f5f859f2fa213fc2f43a6052c65'
            '67279b75c3b44d065811c9c90aee006296164000912d5bb97c74956b26ee4ad4f0847e846052a896d379848b869c849300367e676d3f689cf29e3a0c7ae5310b')

prepare() {
  # Fix for new pymongo
  patch -d "$_pkgname-$pkgver" -p1 -i \
    ../89c4573ac47a1f840ed2d15e2820d0eaed29dc32.patch

  sed -i -e 's/==/>=/' -e 's/< *4.4/<6/' "celery-$pkgver/requirements/test.txt"
}

build() {
  cd "$_pkgname-$pkgver"

  python2 setup.py build
}

package() {
  cd "$_pkgname-$pkgver"

  python2 setup.py install --root="$pkgdir" -O1 --skip-build

  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm 644 "$srcdir/celery@.service" \
    "$pkgdir/usr/lib/systemd/system/celery2@.service"
  install -Dm 644 "$srcdir/celery.tmpfiles.d" \
    "$pkgdir/usr/lib/tmpfiles.d/celery2.conf"

  mv "$pkgdir/usr/bin/$_pkgname" "$pkgdir/usr/bin/${_pkgname}2"
}

